<?php include("../config.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title><?php echo $sitename; ?> - Sysop: Manage Users Reviews</title>
<meta name="description" content="<?php echo $sitename; ?> - Sysop: Manage Users Reviews">
<meta name="keywords" content="free to try, software, shareware, freeware, developers, vendors, download, PAD">
<meta name="author" content="Andrey Aleksanyants, M.D.">
<meta name="copyright" content="easy HTools">
<meta http-equiv="imagetoolbar" content="no">
<link rel="stylesheet" type="text/css" href="../<?php echo $cssfile; ?>">
<link rel="shortcut icon" href="../favicon.ico">
</head>
<body>
<table class="tmain" align="center" width="90%" cellspacing="0" cellpadding="0">
<tr>
<td class="tmain">
<table class="tlogo" align="center" width="100%" cellspacing="0" cellpadding="4">
<tr>
<td align="right">
<p><a href="index.php">Home</a> :: <a href="logout.php">Logout</a></p>
</td>
</tr>
</table>
</td>
</tr><tr>
<td class="tmain">
<br>
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="1">
<tr valign="top">
<td class="tbody">
<h1><?php echo $sitename; ?> - Sysop: Manage Users Reviews</h1>
<?php

// Connecting to database
if(!($link_id = @mysql_connect($dbhost, $userid, $userpassword))) {
	die("<p><b>Error connecting to the database server:</b> " . mysql_error() . "</p>\n");
}
mysql_select_db($dbname);

$numrev = 0;
$result = mysql_query("SELECT * FROM usrreviews", $link_id);
if($result) $numrev = mysql_num_rows($result);
echo "<p><b>Total reviews:</b> " . $numrev . "</p><br>\n";

// Requesting data from Add PAD List form on /sysop/index.php
$date1    = $_POST["date1"];
$submit   = $_POST["submit"];

if(empty($submit)) {
	echo "<form action=\"" . $PHP_SELF . "\" method=\"post\">\n";
	echo "<table class=\"tvisible\" align=\"center\" cellspacing=\"0\" cellpadding=\"4\">\n";
	echo "<tr>\n";
	echo "<th class=\"tablehead\" colspan=\"2\">Manage Users Reviews</th>\n";
	echo "</tr><tr>\n";
	echo "<td class=\"tdark\"><p><b>Posted since:</b></p></td>\n";
	echo "<td><input type=\"text\" name=\"date1\" value=\"" . date("Y-m-d") . "\" size=\"12\"></td>\n";
	echo "</tr><tr>\n";
	echo "<td class=\"tdark\"><p><b>Display:</b></p></td>\n";
	echo "<td><input type=\"submit\" class=\"button\" name=\"submit\" value=\" Display \"></td>\n";
	echo "</tr>\n</table>\n</form>\n<br>\n";
}
else {
	
	$result = mysql_query("SELECT * FROM usrreviews WHERE revtime > '$date1' ORDER BY revtime DESC", $link_id);
	echo "<p>Records found: " . mysql_num_rows($result) . "</p><br>\n";

	$n = 0;
	if($result) $n = mysql_num_fields($result);
	if($n > 0) {
		echo "<table class=\"tvisible\" width=\"100%\" cellSpacing=\"0\" cellPadding=\"4\">\n";
		echo "<tr>\n";
		echo "<th class=\"tablehead\">No.</th>\n";
		for($i=0; $i<$n; $i++) echo "<th class=\"tablehead\">" . mysql_field_name($result,$i) . "</th>\n";
		echo "<th class=\"tablehead\">Remove</th>";
		echo "</tr>";
		
		$count = 0;
		while($query = mysql_fetch_row($result)) {
			$count++;
			echo "<tr><td>" . $count . "</td>";
				for($i=0; $i<$n; $i++) {
					echo "<td><p>" . htmlspecialchars($query[$i]) . "</p></td>";
				}
			echo "<td><p><a href=\"usrremove.php?userid=" . $query[0] . "\">Remove</a></p></td>";
			echo "</tr>";
		}
		echo "</table>\n<br>\n";
	}
}
// Disconnect from database
mysql_close($link_id);
?>
<br>

</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
